/**
 * 文章请求模块
 */
import request from '@/utils/request'

/**
  * 获取文章列表  频道新闻推荐_V1.1
  */
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params
  })
}

/**
 * 获取文章详情
 * @param {Number} id 文章id
 * @returns promise
 */
export const getArticleInfo = id => {
  return request({
    method: 'GET',
    url: '/v1_0/articles/' + id,
    id
  })
}

/**
 * 收藏文章
 * @param {Number} target 文章id
 * @returns promise
 */
export const addArticleCollected = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

/**
 * 取消文章收藏
 * @param {Number} target 文章id
 * @returns promise
 */
export const deleteArticleCollected = target => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/collections/' + target

  })
}

/**
 * 对文章点赞
 * @param {Number} target 文章id
 * @returns promise
 */
export const addArticleLikings = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

/**
 * 取消文章点赞
 * @param {Number} target 文章id
 * @returns promise
 */
export const deleteArticleLikings = target => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + target

  })
}
